<html>
<head><meta charset="utf-8"><title>Duplicated Diagnostics · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Duplicated.20Diagnostics.html">Duplicated Diagnostics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="222813463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Duplicated%20Diagnostics/near/222813463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Duplicated.20Diagnostics.html#222813463">(Jan 15 2021 at 02:41)</a>:</h4>
<p>Hello, I'm trying to debug the issue 6851 from rust-analyzer and I'm new here. I found that I could remove the duplicated code actions I had by commenting lines 314-341 on <code>crates/rust-analyzer/src/diagnostics/to_proto.rs</code>. Is this solution OK or it would not be the way to go? <span class="user-mention" data-user-id="133169">@matklad</span> commented on issue 6734 that those "related information" diagnostics were not useful for VS code. <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="222815252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Duplicated%20Diagnostics/near/222815252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Duplicated.20Diagnostics.html#222815252">(Jan 15 2021 at 03:13)</a>:</h4>
<p>I don't think that would be the right way, it would basically undo the PR that showed more detailed rustc diagnostics</p>



<a name="222815271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Duplicated%20Diagnostics/near/222815271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Duplicated.20Diagnostics.html#222815271">(Jan 15 2021 at 03:13)</a>:</h4>
<p>Instead we shouldn't duplicate the <code>fixes</code> onto each diagnostic we return</p>



<a name="222816114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Duplicated%20Diagnostics/near/222816114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Duplicated.20Diagnostics.html#222816114">(Jan 15 2021 at 03:31)</a>:</h4>
<p>Oh, thanks. Now I see that it isn't a good option. I'll think more about it later.</p>



<a name="222851087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Duplicated%20Diagnostics/near/222851087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Duplicated.20Diagnostics.html#222851087">(Jan 15 2021 at 12:31)</a>:</h4>
<p>I can look at this too</p>



<a name="222884621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Duplicated%20Diagnostics/near/222884621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Duplicated.20Diagnostics.html#222884621">(Jan 15 2021 at 16:36)</a>:</h4>
<p>That looks hard to deal with.  Some things work on some diagnostics, others don't... The best "fix" I could find so far was to skip related_information diagnostics when it starts on the same line as the primary span. It worked for the cases I was testing manually.</p>
<p>Something like this around line 324: </p>
<div class="codehilite"><pre><span></span><code>if info.message.is_empty() || same_line {
    continue;
}
</code></pre></div>
<p>The idea was to limit the amount of fixes to 1 on the same spot and primary span. This may work for most cases, though maybe not of them.... <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="222891052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Duplicated%20Diagnostics/near/222891052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Duplicated.20Diagnostics.html#222891052">(Jan 15 2021 at 17:14)</a>:</h4>
<p><span class="user-mention" data-user-id="312608">@Eduardo Canellas</span> I'd be surprised if we need to do that, it should suffice to just emit fixes alongside the diagnostic that includes them, instead of collecting and duplicating them with each subdiagnostic. Can you give <a href="https://github.com/rust-analyzer/rust-analyzer/pull/7285">https://github.com/rust-analyzer/rust-analyzer/pull/7285</a> a try to see if it fixes the issues? It works for me.</p>



<a name="222906494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Duplicated%20Diagnostics/near/222906494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Duplicated.20Diagnostics.html#222906494">(Jan 15 2021 at 18:54)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> I tried it and it fixed the issues I was testing. <span aria-label="happy" class="emoji emoji-1f600" role="img" title="happy">:happy:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>